
****************************************************************************************************
*
* Replication file for: 
*
* Evelyne Hübscher, Thomas Sattler, Markus Wagner. Forthcoming. "Does Austerity Cause Polarization?"
* British Journal of Political Science
*
* Micro Analysis, file 2/2
*
****************************************************************************************************
*
* Date: November 7, 2022
* 
* Software: Stata 17 (note: coefplot and combomarginsplot need to be installed)
*
*
* Figures A13
* -----------
*
* Outcome: 0 = CL, 1 = CR, 2 = Other/Abstention (with fourth treatment)

foreach Country in Germany UK Spain Portugal {

	use Data/HSW_BJPS_Micro_`Country'PW.dta, clear
	
	* recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) //1 Both keep, 2 R cut, 3 Both cut

	mlogit E3vote2 ib4.policy##i.government i.E3realvote2 age i.eisced Q1010 i.gender econid , cl(id)
	margins, dydx(policy) pr(out(0)) 
	matrix margins=r(b)'
	matrix err=r(V)
	svmat margins
	rename margins1 margins
	gen serr=.
	replace serr=sqrt(err[1,1]) in 1
	replace serr=sqrt(err[2,2]) in 2
	replace serr=sqrt(err[3,3]) in 3
	replace serr=sqrt(err[4,4]) in 4

	margins, dydx(policy) pr(out(1))
	matrix a=[.\.\.\.]
	matrix margins2=a\r(b)'
	svmat margins2
	replace margins=margins2 in 5/8
	matrix err=r(V)
	replace serr=sqrt(err[1,1]) in 5
	replace serr=sqrt(err[2,2]) in 6
	replace serr=sqrt(err[3,3]) in 7
	replace serr=sqrt(err[4,4]) in 8

	margins, dydx(policy) pr(out(2))
	matrix margins3=a\a\r(b)'
	svmat margins3
	replace margins=margins3 in 9/12
	matrix err=r(V)
	replace serr=sqrt(err[1,1]) in 9
	replace serr=sqrt(err[2,2]) in 10
	replace serr=sqrt(err[3,3]) in 11
	replace serr=sqrt(err[4,4]) in 12

	gen votelo=margins-1.96*serr
	gen votehi=margins+1.96*serr
	gen ignore=(_n==4|_n==8|_n==12)
	gen policy_axis=_n in 1/12
	
	graph twoway (scatter margins policy_axis if ignore!=1, msymbol(o) mcolor(black) msize(medium)) ///
		(rspike votehi votelo policy_axis  if ignore!=1, lcolor(black) lwidth(medium)), legend(off) xtitle("") ///
		yscale(range(-.15 .15)) ylabel(-.15(.05).15) xscale(range(0 12)) title(`Country') ///
		xlabel(2 "R cuts" 3 "L cuts" 1 "Both cut" ///
		6 "R cuts" 7 "L cuts" 5 "Both cut" ///
		10 "R cuts" 11 "L cuts" 9 "Both cut", angle(45)) ///
		xline(4, lpattern(dash)) xline(8, lpattern(dash)) ///
		yline(0, lpattern(dash)) ///
		text(0.15 2 "CR", size(small)) ///
		text(0.15 6 "CL", size(small)) ///
		text(0.15 10 "Oth./Abst.", size(small)) ///
		saving(Output/`Country'policy5full.gph, replace) scheme(plotplain)  nodraw

	drop margins* policy_axis votehi votelo serr

}  

graph combine Output/Germanypolicy5full.gph Output/UKpolicy5full.gph ///
	Output/Spainpolicy5full.gph Output/Portugalpolicy5full.gph, ///
	title("Treatment effects on vote choice (baseline: both keep)", position(12)) rows(2) scheme(plotplain)
graph export Output/FigA13.pdf, as(pdf) replace

erase Output/Germanypolicy5full.gph 
erase Output/UKpolicy5full.gph
erase Output/Spainpolicy5full.gph 
erase Output/Portugalpolicy5full.gph 
 

* Figure 14
* ---------

foreach Country in Germany UK Spain  Portugal {

	use Data/HSW_BJPS_Micro_`Country'PW.dta, clear
	
	recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) // 1 Both keep, 2 R cut, 3 Both cut
	label define policy3 1 "Both keep" 2 "R cuts" 3 "Both cut"
	label values policy3 policy3
	
	logit E3vote1 i.policy3##i.government i.E3realvote2 age i.eisced Q1010 i.gender econid , cl(id)
	margins, dydx(policy3) saving(Output/`Country'margins, replace) 
	
	logit E3vote1 i.policy3##i.government i.E3realvote2 age i.eisced Q1010 i.gender econid [pweight=weighttoess], cl(id)
	margins, dydx(policy3) saving(Output/`Country'marginsw, replace)

}

combomarginsplot Output/Germanymargins Output/UKmargins Output/Spainmargins Output/Portugalmargins ///
	Output/Germanymarginsw Output/UKmarginsw Output/Spainmarginsw Output/Portugalmarginsw, ///
	recast(scatter) recastci(rspike)  yline(0) ///
	labels("Germany" "UK" "Spain" "Portugal" "Germany" "UK" "Spain" "Portugal") scheme(plotplain) ///
	xtitle(Country) title("Treatment effects on vote choice (baseline: both keep)") ///
	ytitle(Pr(Other Party/Abstention)) ///
	plot2opts(msymbol(o) mcolor(black)) ci2opts(lcolor(black)) ///
	plot1opts(mcolor(gs8) msymbol(o)) ci1opts(lcolor(gs8)) ///
	xline(4.5) text(.14 2.5 "Unweighted", size(small)) text(.14 6.5 "Weighted", size(small)) ///
	legend(title({bf:Policy}, size(small)) order(4 3) label(3 "R cuts") label(4 "Both cut")) 
graph export Output/FigA14.pdf, as(pdf) replace

erase Output/Germanymargins.dta 
erase Output/UKmargins.dta 
erase Output/Spainmargins.dta 
erase Output/Portugalmargins.dta
erase Output/Germanymarginsw.dta 
erase Output/UKmarginsw.dta 
erase Output/Spainmarginsw.dta 
erase Output/Portugalmarginsw.dta


* Figure A15
* ----------

foreach Country in Germany UK Spain  Portugal {

	use Data/HSW_BJPS_Micro_`Country'PW.dta, clear
	
	rename Q16_1 leftright
 	recode policy (4=3) (3=.), gen(policy2) // recode L cut to missing
	recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) //1 Both keep, 2 R cut, 3 Both cut
	
	logit E3vote1 i.policy2##i.government i.policy2##c.leftright##c.leftright i.E3realvote1 age ///
		i.eisced Q1010 i.gender econid , cl(id)

	margins, at(policy2=1 leftright=(0(1)10)) 
	marginsplot, recast(line) recastci(rline) xlabel(0 "0" 1 2 3 4 5 "5" 6 7 8 9 10 "10") ///
		ytitle("") scheme(plotplain) yscale(range(.2 .9)) ylabel(.1(.1).9) ///
		xtitle("L-R position") title("Both cut") ///
		saving(Output/`Country'policy_lra.gph, replace) nodraw 

	margins, at(policy2=2 leftright=(0(1)10)) 
	marginsplot, recast(line) recastci(rline) xlabel(0 "0" 1 2 3 4 5 "5" 6 7 8 9 10 "10") ///
		ytitle("") scheme(plotplain) yscale(range(.2 .9)) ylabel(.1(.1).9) ///
		xtitle("L-R position") title("R cuts") ///
		saving(Output/`Country'policy_lrb.gph, replace) nodraw 

	margins, at(policy2=3 leftright=(0(1)10)) 
	marginsplot,  recast(line) recastci(rline) xlabel(0 "0" 1 2 3 4 5 "5" 6 7 8 9 10 "10") ///
		ytitle("") scheme(plotplain) yscale(range(.2 .9)) ylabel(.1(.1).9) ///
		xtitle("L-R position") title("Both keep") ///
		saving(Output/`Country'policy_lrc.gph, replace) nodraw 

	graph combine Output/`Country'policy_lra.gph ///
		Output/`Country'policy_lrb.gph ///
		Output/`Country'policy_lrc.gph, title("`Country'") rows(1) ///
		saving(Output/`Country'policy_lr.gph, replace) nodraw 
		
		erase Output/`Country'policy_lra.gph
		erase Output/`Country'policy_lrb.gph
		erase Output/`Country'policy_lrc.gph

}

graph combine Output/Germanypolicy_lr.gph Output/UKpolicy_lr.gph ///
	Output/Spainpolicy_lr.gph Output/Portugalpolicy_lr.gph , col(2) scheme(plotplain)
graph export Output/FigA15.pdf, as(pdf) replace
 
erase Output/Germanypolicy_lr.gph
erase Output/UKpolicy_lr.gph 
erase Output/Spainpolicy_lr.gph
erase Output/Portugalpolicy_lr.gph


* Figure A16
* ----------
 
foreach Country in Germany UK Spain  Portugal {

	use Data/HSW_BJPS_Micro_`Country'PW.dta, clear
 	
	recode policy (3=.), gen(policy2) // recode L cut to missing 
	recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) //1 Both keep, 2 R cut, 3 Both cut
	
	regress E3vote1 i.policy3##i.government i.policy3##i.E3realvote2 age i.eisced Q1010 i.gender econid , cl(id)
	margins, dydx(policy3) at(E3realvote=(0))  post
	estimates store a
	
	regress E3vote1 i.policy3##i.government i.policy3##i.E3realvote2 age i.eisced Q1010 i.gender econid , cl(id)
	margins, dydx(policy3) at(E3realvote=(1))  post
	estimates store b
	
	regress E3vote1 i.policy3##i.government i.policy3##i.E3realvote2 age i.eisced Q1010 i.gender econid , cl(id)
	margins, dydx(policy3) at(E3realvote=(2))  post
	estimates store c

	coefplot a b c, vertical yline(0) title(`Country') xlabel(1 "R cuts" 2 "Both cut") ///
		legend(title("Prior vote") label(2 "CR") label(4 "CL")  label(6 "Other") position(6) rows(1)) ///
		saving(Output/`Country'policy_vote.gph, replace)  scheme(plotplain)
		
}

graph combine Output/Germanypolicy_vote.gph Output/UKpolicy_vote.gph ///
	Output/Spainpolicy_vote.gph Output/Portugalpolicy_vote.gph, ///
	imargin(0 0 0 0) graphregion(margin(l=22 r=22) ) col(2) ///
	title("Treatment effects on vote choice (baseline: both keep)") scheme(plotplain)
graph export Output/FigA16.pdf, as(pdf) replace
 
erase Output/Germanypolicy_vote.gph 
erase Output/UKpolicy_vote.gph 
erase Output/Spainpolicy_vote.gph 
erase Output/Portugalpolicy_vote.gph
 
 
* Figures A9 - A12
* ---------------- 
*
* - Germany

use Data/HSW_BJPS_Micro_GermanyPW.dta, clear
	
recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) // 1 Both keep, 2 R cut, 3 Both cut
clonevar PWvote2=PWvote
replace PWvote2=. if PWvote2==99

mlogit PWvote2 ib4.policy##i.government i.Q14 , cl(id) 
margins, dydx(policy) pr(out(1)) 
matrix margins=r(b)'
matrix err=r(V)
svmat margins
rename margins1 margins
gen serr=.
replace serr=sqrt(err[1,1]) in 1
replace serr=sqrt(err[2,2]) in 2
replace serr=sqrt(err[3,3]) in 3
replace serr=sqrt(err[4,4]) in 4

margins, dydx(policy) pr(out(2))
matrix a=[.\.\.\.]
matrix margins2=a\r(b)'
svmat margins2
replace margins=margins2 in 5/8
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 5
replace serr=sqrt(err[2,2]) in 6
replace serr=sqrt(err[3,3]) in 7
replace serr=sqrt(err[4,4]) in 8

margins, dydx(policy) pr(out(3))
matrix margins3=a\a\r(b)'
svmat margins3
replace margins=margins3 in 9/12
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 9
replace serr=sqrt(err[2,2]) in 10
replace serr=sqrt(err[3,3]) in 11
replace serr=sqrt(err[4,4]) in 12

margins, dydx(policy) pr(out(4))
matrix margins4=a\a\a\r(b)'
svmat margins4
replace margins=margins4 in 13/16
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 13
replace serr=sqrt(err[2,2]) in 14
replace serr=sqrt(err[3,3]) in 15
replace serr=sqrt(err[4,4]) in 16

margins, dydx(policy) pr(out(5))
matrix margins5=a\a\a\a\r(b)'
svmat margins5
replace margins=margins5 in 17/20
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 17
replace serr=sqrt(err[2,2]) in 18
replace serr=sqrt(err[3,3]) in 19
replace serr=sqrt(err[4,4]) in 20

margins, dydx(policy) pr(out(6))
matrix margins6=a\a\a\a\a\r(b)'
svmat margins6
replace margins=margins6 in 21/24
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 21
replace serr=sqrt(err[2,2]) in 22
replace serr=sqrt(err[3,3]) in 23
replace serr=sqrt(err[4,4]) in 24

margins, dydx(policy) pr(out(77))
matrix margins7=a\a\a\a\a\a\r(b)'
svmat margins7
replace margins=margins7 in 25/28
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 25
replace serr=sqrt(err[2,2]) in 26
replace serr=sqrt(err[3,3]) in 27
replace serr=sqrt(err[4,4]) in 28

margins, dydx(policy) pr(out(88))
matrix margins8=a\a\a\a\a\a\a\r(b)'
svmat margins8
replace margins=margins8 in 29/32
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 29
replace serr=sqrt(err[2,2]) in 30
replace serr=sqrt(err[3,3]) in 31
replace serr=sqrt(err[4,4]) in 32

gen votelo=margins-1.96*serr
gen votehi=margins+1.96*serr
gen ignore=(_n==4|_n==8|_n==12|_n==16|_n==20|_n==24|_n==28|_n==32)
gen policy_axis=_n in 1/32

graph twoway (scatter margins policy_axis if ignore!=1, msymbol(o) mcolor(black) msize(medium)) ///
	(rcap votehi votelo policy_axis  if ignore!=1, lcolor(black) lwidth(medium)), legend(off) xtitle("") ///
	yscale(range(-.15 .15)) ylabel(-.15(.05).15) xscale(range(0 32)) title(`Country') ///
	xlabel(2 "R cuts" 3 "L cuts" 1 "Both cut" ///
	6 "R cuts" 7 "L cuts" 5 "Both cut" ///
	10 "R cuts" 11 "L cuts" 9 "Both cut" ///
	14 "R cuts" 15 "L cuts" 13 "Both cut" ///
	18 "R cuts" 19 "L cuts" 17 "Both cut" ///
	22 "R cuts" 23 "L cuts" 21 "Both cut" ///
	26 "R cuts" 27 "L cuts" 25 "Both cut" ///
	30 "R cuts" 31 "L cuts" 29 "Both cut", angle(45)) ///
	xline(4, lpattern(dash)) xline(8, lpattern(dash)) ///
	xline(12, lpattern(dash)) xline(16, lpattern(dash)) ///
	xline(20, lpattern(dash)) xline(24, lpattern(dash)) ///
	xline(28, lpattern(dash))  ///
	yline(0, lpattern(dash)) ///
	text(0.15 2 "CDU/CSU", size(small)) ///
	text(0.15 6 "SPD", size(small)) ///
	text(0.15 10 "FDP", size(small)) ///
	text(0.15 14 "Green", size(small)) ///
	text(0.15 18 "Left", size(small)) ///
	text(0.15 22 "AfD", size(small)) ///
	text(0.15 26 "Oth.", size(small)) ///
	text(0.15 30 "Abst.", size(small)) ///
	xtitle("Treatment effect, baseline: both keep") scheme(plotplain)
graph export Output/FigA9.pdf, as(pdf) replace

* - UK

use Data/HSW_BJPS_Micro_UKPW.dta, clear
	
recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) //1 Both keep, 2 R cut, 3 Both cut

gen PWvote_new=1 if PWvote==1
replace PWvote_new=2 if PWvote==2
replace PWvote_new=3 if PWvote==3
replace PWvote_new=4 if PWvote==6
replace PWvote_new=5 if PWvote==7
replace PWvote_new=6 if PWvote==4
replace PWvote_new=6 if PWvote==5
replace PWvote_new=6 if PWvote==8
replace PWvote_new=6 if PWvote==77
replace PWvote_new=7 if PWvote==88

gen voteint=1 if Q14==1
replace voteint=2 if Q14==2
replace voteint=3 if Q14==3
replace voteint=4 if Q14==6
replace voteint=5 if Q14==7
replace voteint=6 if Q14==4
replace voteint=6 if Q14==5
replace voteint=6 if PWvote==8
replace voteint=6 if PWvote==77
replace voteint=7 if PWvote==88
replace voteint=8 if PWvote==99

mlogit PWvote_new ib4.policy##i.government i.Q14 , cl(id) 
margins, dydx(policy) pr(out(1)) 
matrix margins=r(b)'
matrix err=r(V)
svmat margins
rename margins1 margins
gen serr=.
replace serr=sqrt(err[1,1]) in 1
replace serr=sqrt(err[2,2]) in 2
replace serr=sqrt(err[3,3]) in 3
replace serr=sqrt(err[4,4]) in 4

margins, dydx(policy) pr(out(2))
matrix a=[.\.\.\.]
matrix margins2=a\r(b)'
svmat margins2
replace margins=margins2 in 5/8
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 5
replace serr=sqrt(err[2,2]) in 6
replace serr=sqrt(err[3,3]) in 7
replace serr=sqrt(err[4,4]) in 8

margins, dydx(policy) pr(out(3))
matrix margins3=a\a\r(b)'
svmat margins3
replace margins=margins3 in 9/12
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 9
replace serr=sqrt(err[2,2]) in 10
replace serr=sqrt(err[3,3]) in 11
replace serr=sqrt(err[4,4]) in 12

margins, dydx(policy) pr(out(4))
matrix margins4=a\a\a\r(b)'
svmat margins4
replace margins=margins4 in 13/16
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 13
replace serr=sqrt(err[2,2]) in 14
replace serr=sqrt(err[3,3]) in 15
replace serr=sqrt(err[4,4]) in 16

margins, dydx(policy) pr(out(5))
matrix margins5=a\a\a\a\r(b)'
svmat margins5
replace margins=margins5 in 17/20
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 17
replace serr=sqrt(err[2,2]) in 18
replace serr=sqrt(err[3,3]) in 19
replace serr=sqrt(err[4,4]) in 20

margins, dydx(policy) pr(out(6))
matrix margins6=a\a\a\a\a\r(b)'
svmat margins6
replace margins=margins6 in 21/24
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 21
replace serr=sqrt(err[2,2]) in 22
replace serr=sqrt(err[3,3]) in 23
replace serr=sqrt(err[4,4]) in 24

margins, dydx(policy) pr(out(7))
matrix margins7=a\a\a\a\a\a\r(b)'
svmat margins7
replace margins=margins7 in 25/28
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 25
replace serr=sqrt(err[2,2]) in 26
replace serr=sqrt(err[3,3]) in 27
replace serr=sqrt(err[4,4]) in 28

gen votelo=margins-1.96*serr
gen votehi=margins+1.96*serr
gen ignore=(_n==4|_n==8|_n==12|_n==16|_n==20|_n==24|_n==28)
gen policy_axis=_n in 1/28

graph twoway (scatter margins policy_axis if ignore!=1, msymbol(o) mcolor(black) msize(medium)) ///
	(rcap votehi votelo policy_axis  if ignore!=1, lcolor(black) lwidth(medium)), legend(off) xtitle("") ///
	yscale(range(-.15 .15)) ylabel(-.15(.05).15) xscale(range(0 28)) title(`Country') ///
	xlabel(2 "R cuts" 3 "L cuts" 1 "Both cut" ///
	6 "R cuts" 7 "L cuts" 5 "Both cut" ///
	10 "R cuts" 11 "L cuts" 9 "Both cut" ///
	14 "R cuts" 15 "L cuts" 13 "Both cut" ///
	18 "R cuts" 19 "L cuts" 17 "Both cut" ///
	22 "R cuts" 23 "L cuts" 21 "Both cut" ///
	26 "R cuts" 27 "L cuts" 25 "Both cut", angle(45)) ///
	xline(4, lpattern(dash)) xline(8, lpattern(dash)) ///
	xline(12, lpattern(dash)) xline(16, lpattern(dash)) ///
	xline(20, lpattern(dash)) xline(24, lpattern(dash)) ///
	yline(0, lpattern(dash)) ///
	text(0.15 2 "Con", size(small)) ///
	text(0.15 6 "Lab", size(small)) ///
	text(0.15 10 "Lib Dem", size(small)) ///
	text(0.15 14 "UKIP", size(small)) ///
	text(0.15 18 "Green", size(small)) ///
	text(0.15 22 "Other", size(small)) ///
	text(0.15 26 "Abst.", size(small)) ///
	xtitle("Treatment effect, baseline: both keep") scheme(plotplain)
graph export Output/FigA10.pdf, as(pdf) replace

* - Spain

use Data/HSW_BJPS_Micro_SpainPW.dta, clear

recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) // 1 Both keep, 2 R cut, 3 Both cut

gen voteint=1 if Q14==1
replace voteint=2 if Q14==2
replace voteint=3 if Q14==4
replace voteint=4 if Q14==4
replace voteint=5 if Q14>=5&Q14<=15
replace voteint=5 if Q14==77
replace voteint=6 if Q14==88
replace voteint=7 if Q14==99

gen PWvote_new=1 if PWvote==1
replace PWvote_new=2 if PWvote==2
replace PWvote_new=3 if PWvote==3
replace PWvote_new=4 if PWvote==4
replace PWvote_new=5 if PWvote>=5&PWvote<=15
replace PWvote_new=5 if PWvote==77
replace PWvote_new=6 if PWvote==88

mlogit PWvote_new ib4.policy##i.government i.voteint , cl(id) 
margins, dydx(policy) pr(out(1)) 
matrix margins=r(b)'
matrix err=r(V)
svmat margins
rename margins1 margins
gen serr=.
replace serr=sqrt(err[1,1]) in 1
replace serr=sqrt(err[2,2]) in 2
replace serr=sqrt(err[3,3]) in 3
replace serr=sqrt(err[4,4]) in 4

margins, dydx(policy) pr(out(2))
matrix a=[.\.\.\.]
matrix margins2=a\r(b)'
svmat margins2
replace margins=margins2 in 5/8
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 5
replace serr=sqrt(err[2,2]) in 6
replace serr=sqrt(err[3,3]) in 7
replace serr=sqrt(err[4,4]) in 8

margins, dydx(policy) pr(out(3))
matrix margins3=a\a\r(b)'
svmat margins3
replace margins=margins3 in 9/12
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 9
replace serr=sqrt(err[2,2]) in 10
replace serr=sqrt(err[3,3]) in 11
replace serr=sqrt(err[4,4]) in 12

margins, dydx(policy) pr(out(4))
matrix margins4=a\a\a\r(b)'
svmat margins4
replace margins=margins4 in 13/16
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 13
replace serr=sqrt(err[2,2]) in 14
replace serr=sqrt(err[3,3]) in 15
replace serr=sqrt(err[4,4]) in 16

margins, dydx(policy) pr(out(5))
matrix margins5=a\a\a\a\r(b)'
svmat margins5
replace margins=margins5 in 17/20
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 17
replace serr=sqrt(err[2,2]) in 18
replace serr=sqrt(err[3,3]) in 19
replace serr=sqrt(err[4,4]) in 20

margins, dydx(policy) pr(out(6))
matrix margins6=a\a\a\a\a\r(b)'
svmat margins6
replace margins=margins6 in 21/24
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 21
replace serr=sqrt(err[2,2]) in 22
replace serr=sqrt(err[3,3]) in 23
replace serr=sqrt(err[4,4]) in 24

gen votelo=margins-1.96*serr
gen votehi=margins+1.96*serr
gen ignore=(_n==4|_n==8|_n==12|_n==16|_n==20|_n==24)
gen policy_axis=_n in 1/24

graph twoway (scatter margins policy_axis if ignore!=1, msymbol(o) mcolor(black) msize(medium)) ///
	(rcap votehi votelo policy_axis  if ignore!=1, lcolor(black) lwidth(medium)), legend(off) xtitle("") ///
	yscale(range(-.15 .15)) ylabel(-.15(.05).15) xscale(range(0 24)) title(`Country') ///
	xlabel(2 "R cuts" 3 "L cuts" 1 "Both cut" ///
	6 "R cuts" 7 "L cuts" 5 "Both cut" ///
	10 "R cuts" 11 "L cuts" 9 "Both cut" ///
	14 "R cuts" 15 "L cuts" 13 "Both cut" ///
	18 "R cuts" 19 "L cuts" 17 "Both cut" ///
	22 "R cuts" 23 "L cuts" 21 "Both cut", angle(45)) ///
	xline(4, lpattern(dash)) xline(8, lpattern(dash)) ///
	xline(12, lpattern(dash)) xline(16, lpattern(dash)) ///
	xline(20, lpattern(dash))  ///
	yline(0, lpattern(dash)) ///
	text(0.15 2 "PP", size(small)) ///
	text(0.15 6 "PSOE", size(small)) ///
	text(0.15 10 "C", size(small)) ///
	text(0.15 14 "UP", size(small)) ///
	text(0.15 18 "Other", size(small)) ///
	text(0.15 22 "Abst.", size(small)) /// 
	xtitle("Treatment effect, baseline: both keep") scheme(plotplain)
graph export Output/FigA11.pdf, as(pdf) replace

* - Portugal

use Data/HSW_BJPS_Micro_PortugalPW.dta, clear

recode policy (1=3) (2=2) (4=1) (3=.), gen(policy3) //1 Both keep, 2 R cut, 3 Both cut
gen PWvote_new=1 if PWvote==1
replace PWvote_new=2 if PWvote==2
replace PWvote_new=3 if PWvote==3
replace PWvote_new=4 if PWvote==5
replace PWvote_new=5 if PWvote==6
replace PWvote_new=6 if PWvote==4
replace PWvote_new=6 if PWvote==7
replace PWvote_new=6 if PWvote==8
replace PWvote_new=6 if PWvote==9
replace PWvote_new=6 if PWvote==77
replace PWvote_new=7 if PWvote==88

mlogit PWvote_new ib4.policy##i.government i.Q14 , cl(id) 
margins, dydx(policy) pr(out(1)) 
matrix margins=r(b)'
matrix err=r(V)
svmat margins
rename margins1 margins
gen serr=.
replace serr=sqrt(err[1,1]) in 1
replace serr=sqrt(err[2,2]) in 2
replace serr=sqrt(err[3,3]) in 3
replace serr=sqrt(err[4,4]) in 4

margins, dydx(policy) pr(out(2))
matrix a=[.\.\.\.]
matrix margins2=a\r(b)'
svmat margins2
replace margins=margins2 in 5/8
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 5
replace serr=sqrt(err[2,2]) in 6
replace serr=sqrt(err[3,3]) in 7
replace serr=sqrt(err[4,4]) in 8

margins, dydx(policy) pr(out(3))
matrix margins3=a\a\r(b)'
svmat margins3
replace margins=margins3 in 9/12
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 9
replace serr=sqrt(err[2,2]) in 10
replace serr=sqrt(err[3,3]) in 11
replace serr=sqrt(err[4,4]) in 12

margins, dydx(policy) pr(out(4))
matrix margins4=a\a\a\r(b)'
svmat margins4
replace margins=margins4 in 13/16
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 13
replace serr=sqrt(err[2,2]) in 14
replace serr=sqrt(err[3,3]) in 15
replace serr=sqrt(err[4,4]) in 16

margins, dydx(policy) pr(out(5))
matrix margins5=a\a\a\a\r(b)'
svmat margins5
replace margins=margins5 in 17/20
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 17
replace serr=sqrt(err[2,2]) in 18
replace serr=sqrt(err[3,3]) in 19
replace serr=sqrt(err[4,4]) in 20

margins, dydx(policy) pr(out(6))
matrix margins6=a\a\a\a\a\r(b)'
svmat margins6
replace margins=margins6 in 21/24
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 21
replace serr=sqrt(err[2,2]) in 22
replace serr=sqrt(err[3,3]) in 23
replace serr=sqrt(err[4,4]) in 24

margins, dydx(policy) pr(out(7))
matrix margins7=a\a\a\a\a\a\r(b)'
svmat margins7
replace margins=margins7 in 25/28
matrix err=r(V)
replace serr=sqrt(err[1,1]) in 25
replace serr=sqrt(err[2,2]) in 26
replace serr=sqrt(err[3,3]) in 27
replace serr=sqrt(err[4,4]) in 28

gen votelo=margins-1.96*serr
gen votehi=margins+1.96*serr
gen ignore=(_n==4|_n==8|_n==12|_n==16|_n==20|_n==24|_n==28)
gen policy_axis=_n in 1/28

graph twoway (scatter margins policy_axis if ignore!=1, msymbol(o) mcolor(black) msize(medium)) ///
	(rcap votehi votelo policy_axis  if ignore!=1, lcolor(black) lwidth(medium)), legend(off) xtitle("") ///
	yscale(range(-.15 .15)) ylabel(-.15(.05).15) xscale(range(0 32)) title(`Country') ///
	xlabel(2 "R cuts" 3 "L cuts" 1 "Both cut" ///
	6 "R cuts" 7 "L cuts" 5 "Both cut" ///
	10 "R cuts" 11 "L cuts" 9 "Both cut" ///
	14 "R cuts" 15 "L cuts" 13 "Both cut" ///
	18 "R cuts" 19 "L cuts" 17 "Both cut" ///
	22 "R cuts" 23 "L cuts" 21 "Both cut" ///
	26 "R cuts" 27 "L cuts" 25 "Both cut", angle(45)) ///
	xline(4, lpattern(dash)) xline(8, lpattern(dash)) ///
	xline(12, lpattern(dash)) xline(16, lpattern(dash)) ///
	xline(20, lpattern(dash)) xline(24, lpattern(dash)) ///
	yline(0, lpattern(dash)) ///
	text(0.15 2 "PS", size(small)) ///
	text(0.15 6 "PSD", size(small)) ///
	text(0.15 10 "BE", size(small)) ///
	text(0.15 14 "PAN", size(small)) ///
	text(0.15 18 "CDS-PP", size(small)) ///
	text(0.15 22 "Other", size(small)) ///
	text(0.15 26 "Abst.", size(small)) ///
	xtitle("Treatment effect, baseline: both keep") scheme(plotplain)
graph export Output/FigA12.pdf, as(pdf) replace

